<?php
class Teachers_model extends CI_Model
{
	public function __construct()
	{
		$this->load->database();
	}

	public function get_teachers()
	{
		$query = $this->db->get('users');
		return $query->result_array();
	}

	public function get_overview($user_id = FALSE,$day_number = FALSE){
		if($user_id === FALSE){
			return;
		}
		if ($day_number === FALSE)
		{
			$day_number = date( "N", time());
		}

		$sql = "SELECT  `teachers_timetables`.`room_name` AS 'room_name',  `teachers_timetables`.`entry_time` AS 'entry_time',  `teachers_timetables`.`exit_time` AS 'exit_time',  `rooms`.`capacity` AS 'capacity',  `users`.`first_name` AS 'first_name',  `users`.`last_name` AS 'last_name' FROM teachers_timetables, rooms, users WHERE ((`teachers_timetables`.`day_number` =?) AND (`rooms`.`name` =  `teachers_timetables`.`room_name`) AND (`users`.`id` =  `teachers_timetables`.`teacher_id`) AND (`users`.`id` !=?)) ORDER BY  `teachers_timetables`.`room_name` ASC";
		$query = $this->db->query($sql, array($day_number, $user_id));
		return $query->result_array();
	}
}